<?php 
 	require_once '../../config.php';
	if(!isset($_SESSION['login']) || $_SESSION['login']!=true){
		header('location:'.$URL_INCLUDES.'/Logueo.php');
		exit();
	}
	include_once $RUTA_INCLUDES.'/Head.php';
	include_once $RUTA_INCLUDES.'/Menu.php';
	
	$order=new Order();
	$datos=$order->datoDistribuidor();
	$distri=$datos['No_'];
	$num=$datos['Name'];
	
	$merchandise=$order->getMerchandise();
	$machines=$order->getMachine();
	$itemProm=$order->getItemPro();
	$err='';
	
	if(isset($_POST['id_cliente'])){
		if($order->insertOrder($_POST)){
			$err=$order->error;
		}
		else{
			$err=$order->error;
		}
	}
	include_once $RUTA_INCLUDES.'/OrderErrores.php';
?>
<!--AQUI EMPIEZO EL CUERPO DE SOLICITUD DE INSTALACION -->
        <div id="containerHolder">
			<div id="container">
        		<div id="sidebar">
                	<ul class="sideNav">
                    	<li><a href="#" class="active" >Order Processing</a></li>
                    	<li><a href="History_order.php" >History order</a></li>
                    </ul>
                    <!-- // FIN .sideNav -->
                </div>    
                <!-- // FIN #sidebar -->
                <!-- h2 stays for breadcrumbs -->
	            <h2>
	            	<a>Order Processing</a> &raquo; 
	            	<a class="active">Insert new order</a>
	            	<span class="fecha"><?php echo $order->getFecha(); ?></span>
	            </h2>
                <div id="main">
					<h3>New Order:</h3>
					<form action="Order_Processing.php" method="post" enctype="multipart/form-data" id="formupdate" name="form1">
                    	<input type="hidden" name="id_cliente" id="id_cliente" value="<?php echo $distri;  ?>">
                    	<fieldset>
                    		<div class="columna2">
                    			<p class="customer">
                    				<label>Account No.:</label>
                    			</p>
                    		</div>
                    		<div class="columna2">
                    			<p class="cust"><?php echo utf8_encode($distri);?></p>
                    			<p class="cust2"><?php echo utf8_encode($num); ?></p>
                    		</div>
	                        	<p><label>Comment:</label><textarea id="comment" name="comment" rows="1" cols="1" maxlength="250"></textarea></p>
	                   			<p><input id="bt_masOrder" type="button" value="New Line" class="bt_addLinea bot_tipo"/></p>
	                   			<div id="nuevaLinea">
	                   				<div id="divGlobal">
		                   				<div class="columna2">
			                   				<p>
			                            		<label>Item:</label>
						                            <select id='item_0' name='item[]' class="sele_tipoItem">
						                            	<option value=""></option>
						                            	<option value="merchandise">Merchandise</option>
						                            	<option value="machine">Machine</option>
						                            	<option value="item">Item Prom</option>
						                            </select>
						                	</p>
					                	</div>
										<div class="columna2">
						                	<p>
			                            		<label>Description:</label>
			                            			<select id="tipoItem_0" name="tipo_item[]" class="sele_tipoMercha textoMaquina">
						                            	<option value="0"></option>
						                            	<option class="tamanoMenor" value=""></option>
						                            </select>
								<!-- CARGO MERCHANDISE -->
						                            <select id="tipoMerchandise_0" name="tipo_merchandise[]" class="sele_tipoMercha textoMaquina oculto">
						                            	<option value="0"></option>
						                            <?php foreach ($merchandise as $info) { ?>
						                            	<option class="tamanoMenor" value="<?php echo $info['No_'];?>"><?php echo $info['Description']?> (<?php echo $info['Sales Unit of Measure']?>)</option>
				                            		<?php }?>
						                            </select>
						        <!-- CARGO MACHINE -->                    
						                            <select id="tipoMachine_0" name="tipo_machine[]" class="sele_tipoMercha textoMaquina oculto">
						                            	<option value="0"></option>
						                            <?php foreach ($machines as $info) { ?>
						                            	<option class="tamanoMenor" value="<?php echo $info['No_'];?>"><?php echo $info['Description']?> (<?php echo $info['Sales Unit of Measure']?>)</option>
				                            		<?php }?>
						                            </select>
						        <!-- CARGO ITEM -->            
						                             <select id="tipoItemP_0" name="tipo_itemP[]" class="sele_tipoMercha textoMaquina oculto">
						                            	<option value="0"></option>
						                            <?php foreach ($itemProm as $info) { ?>
						                            	<option class="tamanoMenor" value="<?php echo $info['No_'];?>"><?php echo $info['Description']?> (<?php echo $info['Sales Unit of Measure']?>)</option>
				                            		<?php }?>
						                            </select>
						                	</p>
					                	</div>
					                	<div class="columna2">
					                		<p>
			                            		<label>Quant.:</label>
			                            		<input type="text" id="quanti_0" name="quanti[]" class="text-medium textCant" maxlength="4" pattern="[0-9]{1,4}"/>
			                            	</p>
					                	</div>
				                	</div>
		                    	</div>
                            <input id="bt_guardar" type="button" value="Save" class="bot_tipo order" />
                        </fieldset>
                    </form>
                </div>
                <!-- // #main -->
                <div class="clear"></div>
            </div>
            <!-- // #container -->
        </div>	
        <!-- // #containerHolder -->
        <!--AQUI TERMINO YO-->
<?php 
	include_once $RUTA_INCLUDES.'/Pie_pagina.php';
?>